package com.woniuxy.utils;

import com.woniuxy.entity.utils.ResponseEntity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: 马宇航
 * @Description: TODO
 * @DateTime: 22/10/11/0011 11:09
 * @Component: 成都蜗牛学苑
 **/
@Component
public class CallOtherServer {
    @Value("${server.port}")
    int port;

    public void setPort(int port) {
        this.port = port;
    }
    //每30s 发送一次 这个服务信息给Order或者第三方服务
    @Scheduled(cron = "*/30 * * * * ?")
    void callOrder(){
        RestTemplate restTemplate = new RestTemplate();
        restTemplate.postForObject("http://localhost:8091/order/"+port,null, ResponseEntity.class);
    }
}
